export default {
  data () {
    return {
      // Model
      addGroupModel: {
        title: '添加群组',
        visible: false,
        confirmLoading: false,
        ref: 'addGroupRef',
        closable: false,
      },

      // props
      modalProps: {
        cancelText: 'Cancel',
        okText: 'Submit',
        // getContainer() {
        //   return document.querySelector('#appMain')
        // },
        okButtonProps: {
          props: {
            shape: 'round',
          },
        },
        cancelButtonProps: {
          props: {
            shape: 'round',
          },
        },
      },
    }
  },

  methods: {
    // modal submit  this.form.resetFields();
    modalSubmit (prop) {
      const _ref = this.$refs[prop.ref]

      prop.confirmLoading = true
      _ref.handleSubmit()
        .then(async () => {
          try {
            this.$notification.success({
              message: '添加群组成功!',
              duration: 1,
            })
            prop.visible = false
            _ref.resetFields()

            _ref.submitCallBack()

            this.$emit('update')
          } catch (error) {
            console.error(error)
          }
        })
        .finally(() => {
          prop.confirmLoading = false
        })
    },

    // modal cancel
    modalCancel (prop) {
      prop.visible = false

      const _ref = this.$refs[prop.ref]

      _ref.resetFields()
    },
  },
}
